var express = require('express');
var router = express.Router();
var models=require('../../models/models')

/**
 * Created by on 2016/8/18.
 */
router.get('/',(req, res)=>{
  if(!req.query.userid)return res.status(400).send('userid should be a number')
  if (!req.query.timelimit)req.query.timelimit=new Date().getTime()
  let redismodel=models.getModel('redismodel')
  redismodel.getUsersJobId(req.query.userid,req.query.timelimit)
	        .then(result=>{
	        	let ids =[]
	        	result.map(r=>ids.push(redismodel.getUsersJobInfor(r)))
	        	Promise.all(ids)
	        		   .then(result1=>res.status(200).json({'code':200,'msg':'success','result':{result:result1}}))
	        		   .catch(err=>res.status(500).json('server error'))
	        })
	        .catch(err=>res.status(500).json('server error'))
})


module.exports = router;

 
